#include "widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
{
    this->camera = new QCamera(this);

    this->imageCapture = new QCameraImageCapture(camera);

    camera->setCaptureMode(QCamera::CaptureStillImage);

    connect(imageCapture,SIGNAL(imageCaptured(int, const QImage &)),
            this,
            SLOT(saveCaptureImage(int , const QImage &)));

    camera->start();
    camera->searchAndLock();
    imageCapture->capture();
    camera->unlock();

}

void Widget::saveCaptureImage(int id, const QImage &preview){
    auto pix = QPixmap::fromImage(preview);
    pix.save("test.png");
}

Widget::~Widget()
{
}

